<template>
  <Card title="告警情况分析">
    <div slot="extra">
      <timeType  @changeTimeType="changeTimeType"></timeType>
    </div>
    <chart  :data="charData"></chart>
  </Card>
</template>

<script>
import chart from "../echarts/chart";
import {alarmEventCount} from '@/api/realtimeData';
import base from '@/mixins/base';
import timeType from "./timeType";
export default {
  mixins:[base],
  components:{chart,timeType},
  name: "alarmEventInfo",
  data(){
    return {
      charData:[]
    }
  },
  mounted() {
    this.getData();
  },
  methods:{
   async getData(){
     let res =!this.orgIds?{}: await alarmEventCount({pOrgId:this.orgIds,dateType:this.dateType});
     let data=_.get(res,'data')||[]
     this.charData=[];
     if(data.length){
       this.charData.push({
         data:this.formatData(data),
         type:'bar'
       })
     }

   },
   formatData(arr=[]){
     let _arr=  arr.map(item=>{
       return {
         label:item.x,
         value:item.y
       }
     })
     return _arr;
   }
  },
}
</script>

<style scoped>

</style>
